package com.sc.ifs.member;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.sc.dal.common.pagination.Page;
import com.sc.dal.common.pagination.PaginationBean;
import com.sc.dal.mapper.member.MemberCardMapper;
import com.sc.dal.model.member.BankInst;
import com.sc.dal.model.member.MemberCard;
import com.sc.service.member.BankInstService;
import com.sc.service.member.MemberCardService;
import com.sc.util.ChanPay.util.BankCodeNameEnum;
import com.sc.util.ChanPay.util.BankUtil;
import com.sc.util.adapter.ConfigBeanAdapter;
import com.sc.util.data.Common;
import com.sc.util.data.Constants;
import com.sc.util.data.DataUtil;
import com.sc.util.data.JudgeUtil;
import com.sc.util.exception.ExceptionEnum;
/**
 * @ClassName: AppMemberCardController
 * @Description: 用户银行卡管理
 * @author LeiJia
 * @date 2017年3月203日下午16：45:44
 * @version V1.0
 */
@RequestMapping("/app/card")
@Controller
public class AppMemberCardController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	
	@Autowired
	private MemberCardService memberCardService;
	
	@Autowired
	private BankInstService  bankInstService;
	
	/**
	 * @Title: cardIsBelongsTheBank
	 * @Description 3.根据银行卡号判断是否是所选择的的开户银行的卡
	 * @param param
	 * @date 2017年3月20日下午14:50:15
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value ="cardIsBelongsTheBank",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> card_cardIsBelongsTheBank(String cardNumber,String bankName){
		Map<String, Object> resultMap=new LinkedHashMap<String, Object>();
		try{
           
            if(Common.isEmpty(bankName)){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_BANK_NAME_ERROR);
    			return resultMap;
            }
            if(Common.isEmpty(cardNumber)){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_NUMBER_ERROR);
    			return resultMap;
            }
            String card_name = BankUtil.getNameOfBank(cardNumber);
            if(card_name.indexOf(bankName) < 0){
            	resultMap.put("cardIsBelongsTheBank", false);
            }else{
            	resultMap.put("cardIsBelongsTheBank", true);
            }
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_ISBLANGTHEBANK_QUERY_FAIL);
			logger.info("判断银行卡所属银行异常!");
		}
		return resultMap;
	}
	/**
	 * @Title: addMemberCard
	 * @Description 添加银行卡号
	 * @param param
	 * @date 2017年3月20日下午14:50:15
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value ="addMemberCard",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> card_addMemberCard(String param){
		Map<String, Object> resultMap=new LinkedHashMap<String, Object>();
		MemberCard card = null;
		try{
            if(Common.isEmpty(param)){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
    			return resultMap;
            }
            card = JSON.parseObject(param, MemberCard.class);  
            if(Common.isEmpty(card.getMemberId())){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
    			return resultMap;
            }
            if(Common.isEmpty(card.getRealName())){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_REAL_NAME_ERROR);
    			return resultMap;
            }
            if(Common.isEmpty(card.getIdNumber())){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_ID_NUMBER_ERROR);
    			return resultMap;
            }
            if(Common.isEmpty(card.getBankName())){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_BANK_NAME_ERROR);
    			return resultMap;
            }
            if(Common.isEmpty(card.getCardNumber())){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_NUMBER_ERROR);
    			return resultMap;
            }
            if(Common.isEmpty(card.getPhone())){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_PHONE_NUMBER_ERROR);
    			return resultMap;
            }
            
            //首先校验输入银行卡号是否属于所选开户银行
            String card_name = BankUtil.getNameOfBank(card.getCardNumber());
            if(JudgeUtil.isHave(card_name, card.getBankName())){
            	card.setCardName(card_name);
            }else{
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_NUMBER_NOT_MATCH_SUCCESS);
    			return resultMap;
            }
            
            //根据银行卡号查询是否保存过该银行卡
            MemberCard mcard = memberCardService.selectByCardNumber(card.getCardNumber());
            if(mcard != null){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_BANK_CARD_HAS_EXIST_SUCCESS);
    			return resultMap;
            }
            card.setInstCode(BankCodeNameEnum.getInstNameByCode(card.getBankName()));
            card.setCreateDate(new Date());
            card.setCreater(card.getMemberId());
            card.setModifier(card.getMemberId());
            card.setModifyDate(new Date());
            card.setIsDelete(Constants.IS_DELETEA);
            
            int inserMemberCardResult =   memberCardService.insert(card);
            if(inserMemberCardResult == 0){
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_INSERT);
    			return resultMap;
            }
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_INSERT);
			logger.info("添加银行卡号异常!");
		}
		return resultMap;
	}
	/**
	 * @Title: bankCardList
	 * @Description 查询开户银行卡列表
	 * @date 2017年3月29日上午10:37:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="bankCardList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> bankCardList(){
		Map<String,Object> resultMap= new LinkedHashMap<String, Object>();
		List<BankInst> instList = null;
		try{
			 BankInst inst = new BankInst();
			 inst.setCardAttribute(Constants.ChanQPayInst.CARD_ATTRIBUTE_PRIVATE); //对公/对私：B/C
			 inst.setCardType(Constants.ChanQPayInst.CARD_TYPE_DC); //卡类型 贷记=CC，借记=DC，综合=GC
			 inst.setPayMode(Constants.ChanQPayInst.PAY_MODE_QPAY); //支付模式ONLINE_BANK(网银支付)；QPAY(快捷支付)；POS（pos支付）
			 
			 instList = bankInstService.selectAllBankInst(inst);
  		     DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS); 
  			 resultMap.put("data",instList );		
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_FAIL);
			
		}
		return resultMap;
	}
	/**
	 * @Title: bankCardList
	 * @Description 查询开户银行卡列表
	 * @date 2017年3月29日上午10:37:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	/*@RequestMapping(value="bankCardList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> bankCardList(){
		Map<String,Object> resultMap= new LinkedHashMap<String, Object>();
		List<RS> rsList =new ArrayList<RS>();
		try{
			// TR tr = AppPay.getCjtBankList();
  	       //  String list =  tr.getPay_inst_list();
  		    // rsList =JSON.parseObject(list, new TypeReference<List<RS>>(){});  
			String bankTr="{\"_input_charset\":\"UTF-8\",\"is_success\":\"T\",\"pay_inst_list\":\"[{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"BOC\\\",\\\"instId\\\":112620010,\\\"instName\\\":\\\"中国银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"ABC\\\",\\\"instId\\\":112620020,\\\"instName\\\":\\\"中国农业银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"ICBC\\\",\\\"instId\\\":112620030,\\\"instName\\\":\\\"中国工商银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"CCB\\\",\\\"instId\\\":112620040,\\\"instName\\\":\\\"中国建设银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"PSBC\\\",\\\"instId\\\":112620050,\\\"instName\\\":\\\"中国邮政储蓄银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"CMB\\\",\\\"instId\\\":112620060,\\\"instName\\\":\\\"招商银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"CMBC\\\",\\\"instId\\\":112620070,\\\"instName\\\":\\\"中国民生银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"CEB\\\",\\\"instId\\\":112620080,\\\"instName\\\":\\\"中国光大银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"SPDB\\\",\\\"instId\\\":112620090,\\\"instName\\\":\\\"浦发银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"CITIC\\\",\\\"instId\\\":112620100,\\\"instName\\\":\\\"中信银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"SZPAB\\\",\\\"instId\\\":112620110,\\\"instName\\\":\\\"平安银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"CIB\\\",\\\"instId\\\":112620120,\\\"instName\\\":\\\"兴业银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"BCCB\\\",\\\"instId\\\":112620130,\\\"instName\\\":\\\"北京银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"GDB\\\",\\\"instId\\\":112620140,\\\"instName\\\":\\\"广发银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"HXB\\\",\\\"instId\\\":112620150,\\\"instName\\\":\\\"华夏银行\\\",\\\"payMode\\\":\\\"QPAY\\\"},{\\\"cardAttribute\\\":\\\"C\\\",\\\"cardType\\\":\\\"CC\\\",\\\"instCode\\\":\\\"BOS\\\",\\\"instId\\\":112620160,\\\"instName\\\":\\\"上海银行\\\",\\\"payMode\\\":\\\"QPAY\\\"}]\",\"sign\":\"vyM6MfH3YACharX9B9qvtq17PDX+7DN/ancfuGmACALOSP1HmppUThXCiu9V/Iz5ZvU05KrJpu7Bg1GjXJHBJq7tb32edAidyV5rnHbOAfIObQYIF/4HROqJsmUXa15tmiC5VKIthffysVlm3xfNXSh1/U8xB8M2bYPQ7hdn1Ho=\",\"sign_type\":\"RSA\"}";
	//		String bankTr ="{\"_input_charset\":\"UTF-8\",\"is_success\":\"T\",\"pay_inst_list\":\"[{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"BOC\",\"instId\":112620010,\"instName\":\"中国银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"ABC\",\"instId\":112620020,\"instName\":\"中国农业银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"ICBC\",\"instId\":112620030,\"instName\":\"中国工商银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CCB\",\"instId\":112620040,\"instName\":\"中国建设银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"PSBC\",\"instId\":112620050,\"instName\":\"中国邮政储蓄银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CMB\",\"instId\":112620060,\"instName\":\"招商银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CMBC\",\"instId\":112620070,\"instName\":\"中国民生银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CEB\",\"instId\":112620080,\"instName\":\"中国光大银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"SPDB\",\"instId\":112620090,\"instName\":\"浦发银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CITIC\",\"instId\":112620100,\"instName\":\"中信银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"SZPAB\",\"instId\":112620110,\"instName\":\"平安银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CIB\",\"instId\":112620120,\"instName\":\"兴业银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"BCCB\",\"instId\":112620130,\"instName\":\"北京银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"GDB\",\"instId\":112620140,\"instName\":\"广发银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"HXB\",\"instId\":112620150,\"instName\":\"华夏银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"BOS\",\"instId\":112620160,\"instName\":\"上海银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"BOC\",\"instId\":112310010,\"instName\":\"中国银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"ABC\",\"instId\":112310020,\"instName\":\"中国农业银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\//":\"DC\",\"instCode\":\"ICBC\",\"instId\":112310030,\"instName\":\"中国工商银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CCB\",\"instId\":112310040,\"instName\":\"中国建设银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"COMM\",\"instId\":112310050,\"instName\":\"交通银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"PSBC\",\"instId\":112310060,\"instName\":\"中国邮政储蓄银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CMB\",\"instId\":112310070,\"instName\":\"招商银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CMBC\",\"instId\":112310080,\"instName\":\"中国民生银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CEB\",\"instId\":112310090,\"instName\":\"中国光大银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CITIC\",\"instId\":112310110,\"instName\":\"中信银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"SZPAB\",\"instId\":112310120,\"instName\":\"平安银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"BCCB\",\"instId\":112310140,\"instName\":\"北京银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"GDB\",\"instId\":112310150,\"instName\":\"广发银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"HXB\",\"instId\":112310160,\"instName\":\"华夏银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"HKBEA\",\"instId\":112310190,\"instName\":\"东亚银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"NBCB\",\"instId\":112310200,\"instName\":\"宁波银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"NJCB\",\"instId\":112310210,\"instName\":\"南京银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"SPDB\",\"instId\":112310220,\"instName\":\"浦发银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"SHRCB\",\"instId\":112310230,\"instName\":\"上海农村商业银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CIB\",\"instId\":112310240,\"instName\":\"兴业银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"BOC\",\"instId\":112410010,\"instName\":\"中国银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"ABC\",\"instId\":112410020,\"instName\":\"中国农业银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"ICBC\",\"instId\":112410030,\"instName\":\"中国工商银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CCB\",\"instId\":112410040,\"instName\":\"中国建设银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"COMM\",\"instId\":112410050,\"instName\":\"交通银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CMB\",\"instId\":112410070,\"instName\":\"招商银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CMBC\",\"instId\":112410080,\"instName\":\"中国民生银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CEB\",\"instId\":112410090,\"instName\":\"中国光大银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"CITIC\",\"instId\":112410110,\"instName\":\"中信银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"BCCB\",\"instId\":112410140,\"instName\":\"北京银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"GDB\",\"instId\":112410150,\"instName\":\"广发银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"HXB\",\"instId\":112410160,\"instName\":\"华夏银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"NJCB\",\"instId\":112410210,\"instName\":\"南京银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"SPDB\",\"instId\":112410220,\"instName\":\"浦发银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"SHRCB\",\"instId\":112410240,\"instName\":\"上海农村商业银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"CC\",\"instCode\":\"SZPAB\",\"instId\":112410250,\"instName\":\"平安银行\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"BOC\",\"instId\":112710010,\"instName\":\"中国银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"ABC\",\"instId\":112710020,\"instName\":\"中国农业银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"ICBC\",\"instId\":112710030,\"instName\":\"中国工商银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CCB\",\"instId\":112710040,\"instName\":\"中国建设银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CIB\",\"instId\":112710070,\"instName\":\"兴业银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"BOS\",\"instId\":112710080,\"instName\":\"上海银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"BCCB\",\"instId\":112710090,\"instName\":\"北京银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"SPDB\",\"instId\":112710110,\"instName\":\"浦发银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CEB\",\"instId\":112710120,\"instName\":\"中国光大银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CMBC\",\"instId\":112710130,\"instName\":\"中国民生银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"GDB\",\"instId\":112710140,\"instName\":\"广发银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"CITIC\",\"instId\":112710150,\"instName\":\"中信银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"DC\",\"instCode\":\"SZPAB\",\"instId\":112710160,\"instName\":\"平安银行\",\"payMode\":\"QPAY\"},{\"cardAttribute\":\"C\",\"cardType\":\"GC\",\"instCode\":\"WXPAY\",\"instId\":112830010,\"instName\":\"微信扫码\",\"payMode\":\"ONLINE_BANK\"},{\"cardAttribute\":\"C\",\"cardType\":\"GC\",\"instCode\":\"ALIPAY\",\"instId\":112910020,\"instName\":\"支付宝扫码\",\"payMode\":\"ONLINE_BANK\"}]\",\"sign\":\"vyM6MfH3YACharX9B9qvtq17PDX+7DN/ancfuGmACALOSP1HmppUThXCiu9V/Iz5ZvU05KrJpu7Bg1GjXJHBJq7tb32edAidyV5rnHbOAfIObQYIF/4HROqJsmUXa15tmiC5VKIthffysVlm3xfNXSh1/U8xB8M2bYPQ7hdn1Ho=\",\"sign_type\":\"RSA\"}";
			TR tr =  JSON.parseObject(bankTr, TR.class);
//			TR tr =AppPay.getCjtBankList();
		    String list =  tr.getPay_inst_list();
		    rsList=JSON.parseObject(list, new TypeReference<List<RS>>(){});  
			            
  		     DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS); 
  			 resultMap.put("data",rsList );		
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_FAIL);
			
		}
		return resultMap;
	}*/
	/**
	 * @Title: memberCardsList
	 * @Description 查询用户银行卡列表
	 * @param currPage
	 * @param pageSize
	 * @param memberId 
	 * @date 2017年3月20日下午14:34:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value ="memberCardsList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> card_memberCardsList(String memberId){
		Map<String, Object> resultMap=new LinkedHashMap<String, Object>();
		List<MemberCard> resultList = new ArrayList<MemberCard>();
		try{
			if(Common.isEmpty(memberId)){				
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
				return resultMap;
			}
			MemberCard card = new MemberCard();
			card.setMemberId(memberId);			
			resultList = memberCardService.selectByParam(card);	
		    if(resultList != null && resultList.size() >0){
		    	for(MemberCard c : resultList){
		    		if(Common.isNotEmpty(c.getPicture())){
			    		c.setPicture(ConfigBeanAdapter.fileAccessAddress+c.getPicture());
		    		}
		    	}
		    }
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
			logger.info("分页查询银行卡列表异常!");
		}
		resultMap.put("data", resultList);
		return resultMap;
	}
	/**
	 * @Title: memberCardsList
	 * @Description 查询用户银行卡列表
	 * @param currPage
	 * @param pageSize
	 * @param memberId 
	 * @date 2017年3月20日下午14:34:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value ="card_memberCardsListPage",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> card_memberCardsListPage(Integer currPage,Integer pageSize,String memberId){
		Map<String, Object> resultMap=new LinkedHashMap<String, Object>();
		List<MemberCard> resultList = new ArrayList<MemberCard>();
		int totalRecords = 0;
		int totalPage = 0;
		try{
			if(currPage == null || pageSize == null || Common.isEmpty(memberId)){				
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
				return resultMap;
			}
			MemberCard card = new MemberCard();
			card.setMemberId(memberId);
			Page page = new Page();
			// 传入页号
			page.setCurrPage(currPage);
			// 传入每页记录数
			page.setPageSize(pageSize);
			PaginationBean<MemberCard> result = memberCardService.getPagingDatas(card,
					page, "count", "selectByParam",MemberCardMapper.class);
			resultList = result.getPageList();
			totalRecords = result.getTotalRecords();
			totalPage = result.getTotalPage();	
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
			logger.info("分页查询银行卡列表异常!");
		}
		resultMap.put("count", totalRecords);
		resultMap.put("pages", totalPage);
		resultMap.put("data", resultList);
		return resultMap;
	}
}
